home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / vmmngr.zip / VMMTEST2.PAS < prev   
Pascal/Delphi Source File  |  1990-07-16  |  2KB  |  58 lines

  1. program VmmTest2;
  2. {-Test program for VMM. This test is much more severe than real world}
  3. { applications. So don't be afraid by the time it requires to execute}
  4.  
  5. uses
  6.   Dos,
  7.   Vmmngr;
  8.  
  9. type
  10.   BytePtr = ^Byte;
  11.  
  12. const
  13.   AMax = 200;
  14.   SwapFNames : array [1..2] of pathstr = ('VMM1.SWP', 'VMM2.SWP');
  15.  
  16. var
  17.   VM  : array [1..2] of Vmm;
  18.   A   : array [1..2,1..AMax] of BytePtr;
  19.   i,j : Word;
  20.  
  21. begin
  22.   for i := 1 to 2 do begin
  23.     if not VM[i].Init(SwapFNames[i]) then begin
  24.       Writeln('Failed to open virtual memory managers');
  25.       Halt;
  26.     end
  27.     else
  28.       Writeln('Virtual Memory Manager #', i, ' initialized');
  29.     (*
  30.     VM[i].vmOptionsOff(vmDeleteSwap); {Uncomment to examine the swap file}
  31.     *)
  32.     {Link object to dereference handler}
  33.     VM[i].LinkToDerefHandler;
  34.     Writeln('Allocating memory blocks for manager #',i, '...');
  35.     for j := 1 to AMax do begin
  36.       VM[i].GetMemV(A[i][j], j*100);
  37.       if A[i][j] <> nil then
  38.         FillChar(VmmDrf(A[i][j])^, j*100, j mod 255);
  39.     end;
  40.     Writeln('Dereferencing manager #', i, ' pointers again...');
  41.     for j := AMax downto 1 do
  42.       if A[i][j] <> nil then
  43.         FillChar(VmmDrf(A[i][j])^, j*100, 255 - j mod 255);
  44.   end;
  45.   for i := 1 to 2 do begin
  46.     (*
  47.     VM[i].LinkToDerefHandler; {not mandatory here but good practice}
  48.     *)
  49.     Writeln('Deallocating blocks in manager #', i);
  50.     for j := 1 to AMax do
  51.       if A[i][j] <> nil then
  52.         VM[i].FreeMemV(A[i][j]);
  53.     Writeln('Destroying memory manager #', i,'...');
  54.     VM[i].Done;
  55.     Writeln('Manager #', i, ' done.');
  56.   end;
  57. end.
  58.